package yongxin.controller.reports;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.json.AjaxJson;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.constant.Globals;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.web.system.service.SystemService;
import org.jeecgframework.core.util.MyBeanUtils;

import yongxin.entity.process.ProcessEntity;
import yongxin.entity.processreport.ProcessReportEntity;
import yongxin.entity.tasks.TasksEntity;
import yongxin.service.process.ProcessServiceI;
import yongxin.service.processreport.ProcessReportServiceI;
import yongxin.service.tasks.TasksServiceI;

/**   
 * @Title: Controller
 * @Description: 工序汇报任务单
 * @author zhangdaihao
 * @date 2015-02-05 11:44:08
 * @version V1.0   
 *
 */
@Controller
@RequestMapping("/rateReportController")
public class RateReportController extends BaseController {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(RateReportController.class);

	@Autowired
	private TasksServiceI tasksService;
	@Autowired
	private SystemService systemService;
	
	private String message;
	
	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}


	/**
	 * 工序汇报任务单列表 页面跳转
	 * 
	 * @return
	 */
	@RequestMapping(params = "rate")
	public ModelAndView tasks(HttpServletRequest request) {
		return new ModelAndView("yongxin/reports/rateReportList");
	}

	/**
	 * easyui AJAX请求数据
	 * 
	 * @param request
	 * @param response
	 * @param dataGrid
	 * @param user
	 */

	@RequestMapping(params = "datagrid")
	public void datagrid(TasksEntity tasks,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
		//CriteriaQuery cq = new CriteriaQuery(TasksEntity.class, dataGrid);
		//查询条件组装器
		//org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tasks, request.getParameterMap());
		//this.tasksService.getDataGridReturn(cq, true);
		//TagUtil.datagrid(response, dataGrid);
		String fbcph=request.getParameter("fbcph");
		String sql = " select * from t_tasks where fstate = '1' ";
		String sql2 = " select * from t_tasks where fstate = '1' and fbcph like ?";
		List<Map<String,Object>> maplist=null;
		if(fbcph == null || fbcph.trim().equals("")){
			maplist=systemService.findForJdbc(sql);
		}else{
			fbcph = "%" + fbcph + "%";
		    maplist=systemService.findForJdbc(sql2,fbcph);
		}
	
	    dataGrid.setTotal(maplist.size());
		dataGrid.setResults(maplist);
		TagUtil.datagrid(response, dataGrid);
	
	}

}
